package com.yunji.storage.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.storage.bo.StockTakeInfoListQueryBO;
import com.yunji.storage.dao.IStockTakeInfoDao;
import com.yunji.storage.domain.StockTakeInfoDO;
import com.yunji.storage.mapper.StockTakeInfoMapper;
import org.springframework.stereotype.Repository;

import java.util.Arrays;
import java.util.List;

@Repository
public class StockTakeInfoDaoImpl extends BaseDaoImpl<StockTakeInfoMapper, StockTakeInfoDO> implements IStockTakeInfoDao {
    @Override
    public List<StockTakeInfoDO> search(StockTakeInfoListQueryBO bo) {
        return list(new LambdaQueryWrapper<StockTakeInfoDO>()
                .eq(BeanUtils.isNotNull(bo.getStocktakeId()), StockTakeInfoDO::getStocktakeId, bo.getStocktakeId()));
    }

    @Override
    public boolean deleteBYStockTakeIds(Long... stockTakeIds) {
        return remove(new LambdaQueryWrapper<StockTakeInfoDO>()
                .in(StockTakeInfoDO::getStocktakeId, Arrays.asList(stockTakeIds)));
    }
}
